#include <assert.h>
#include "scr_game.h"
#include "scr_basic_sprite.h"
#include "scr_rect.h"
#include "scr_texture.h"
#include "scr_camera.h"

SCRBasicSprite::SCRBasicSprite(SCRTexturePtr Texture, const int& FrameWidth, const int FrameHeight,
	const int& OffsetX, const int& OffsetY)
	: m_Texture(Texture)
	, m_FrameWidth(FrameWidth)
	, m_FrameHeight(FrameHeight)
	, m_OffsetX(OffsetX)
	, m_OffsetY(OffsetY)
{
}

SCRBasicSprite::~SCRBasicSprite()
{
}

void SCRBasicSprite::Draw(const int& X, const int& Y, const int& FrameX, const int& FrameY)
{
	assert(SCRGame::GetInstance());

	const SCRRect DestRect(
		X - m_OffsetX - SCRGame::GetInstance()->GetCamera()->GetX(),
		Y - m_OffsetY - SCRGame::GetInstance()->GetCamera()->GetY(),
		m_FrameWidth, m_FrameHeight);
	const SCRRect SourceRect(FrameX * m_FrameWidth, FrameY * m_FrameHeight, m_FrameWidth, m_FrameHeight);
	m_Texture->Draw(DestRect, SourceRect);
}
